<!--
 * Date: 2018年01月02日 09:32:33
 * LastEditors: lvyou
 * LastEditTime: 2019年12月15日 10:08:58
 * FilePath: \youlinweb-master\src\pages\index\index.vue
 * copyright(c) 2019-2025 版权为浙江双城网络科技集团有限公司所有，违者必究。
 -->
<template>
  <div>
    <ylheader :leftsvg='true' :title="'幸福生活秀'" :rightsvg="true" @search="searchindex"></ylheader>
    <div class="loadmore-container" ref="indexWrapper">
      <div class="loadmore-ul">
        <mt-swipe :auto="5000" style="width: 100%;height: 3.8rem;position:relative" :class="{nofocuspic:isfousexist}" :showIndicators="false" @change="handleChange">
          <mt-swipe-item v-for="(item,index) in urls" :key="index">
            <img @click="turnSkipUrl(item,4)" v-lazy="item.url" class="swiper-img" />
            <!--轮播图提示点背景-->
            <div> <img src="~img/indexswipeback.png" class="swipeindicatorback"></div>
            <!--轮播图提示点-->
            <div class="swipeindicator">
              <div class="swipeindicatorselecet">0{{swipeindex+1}}</div>/ 0{{urls.length}}</div>
          </mt-swipe-item>
        </mt-swipe>

        <!-- 轮播图下面的三个icon -->
        <div class="indexhoticon">
          <router-link to="/topic" @click.native="turn2Topic" class="indexhoticonall">
            <div>
              <div style="position:relative"><img src="~img/huatiicon.png" class="indexhoticonimg"> <img src="~img/hoticon.png" class="hoticon" v-show="hotConfig.topic=='1'"></div>
              <div class="hot-icon-title">话题</div>
            </div>
          </router-link>

          <router-link to="/shuoshuo" @click.native="turn2say" class="indexhoticonall">
            <div>
              <div style="position:relative"><img src="~img/shuoshuo.png" class="indexhoticonimg"><img src="~img/hoticon.png" class="hoticon"  v-show="hotConfig.says=='1'"></div>
              <div class="hot-icon-title">说说</div>
            </div>
          </router-link>

          <router-link to="/replace" @click.native="turn2place" class="indexhoticonall" >
            <div>
              <div style="position:relative"><img src="~img/xianzhi.png" class="indexhoticonimg"><img src="~img/hoticon.png" class="hoticon"  v-show="hotConfig.replaced=='1'"></div>
              <div class="hot-icon-title">闲置</div>
            </div>
          </router-link>

            <div @click="gorotate" class="indexhoticonall" style="border-right:0px" >
              <div style="position:relative"><img src="~img/home-qian.png" class="indexhoticonimg"><img src="~img/hoticon.png" class="hoticon"  v-show="hotConfig.sign=='1'"></div>
              <div class="hot-icon-title" >{{rotatetext}}</div>
            </div>

        </div>

        <!--热门头条-->
        <div class="all-top-headlines" :class="{nodata:isheadlineempty}">
          <div class="headlines">
            <div class="top-headlines" @click="showEruda"> </div>
            <div class="marquee-all">
              <marquee>
                <marquee-item v-for="(items,index) in headline" :key="index" @click.native="headlineclick(items)">  <div class="top-headlines-fa"><span class="top-headlines-label" v-if="items.label!=''">{{items.label}}</span><span class="top-headlines-title">{{items.title}}</span></div></marquee-item>
              </marquee>
            </div>
          </div>
        </div>
        <!--试用试吃-->
         <router-link  :to="{path:'/tryoutgoodslist',query:{tag:0}}" v-if="tryoutConfig">
            <div class="tryeat"><img v-lazy.container="tryoutConfig.pictureUrl"></div>
         </router-link>
        <!-- 热门话题 -->
        <div v-for="(items,index) in nothotopiclist" :key="index">
             <hottopicnew @click.native="totopicdetail(items,10)" :topicimg="items.topicPicture" :abbreviations="items.abbreviations" :followNumber="items.followNumber" :title="items.title" :topictype="items.isShow" :isindex="true" :hotName="items.hotName" :topiclistfa="0">
              </hottopicnew>
          <div class="hot-discuss" v-if="items.discussLists!=''">
            <div v-for="(item,i) in items.discussLists" :key="i">
              <hotheader :topicindex="index" :commentindex="i" :nickname="item.nickName" :avatarimg="item.headImg" :topictime="item.time" @topiccommentdetail="totopiccomdet" :type="0" :userType="item.userType"  :isTalent="item.isTalent" :pendantType="item.pendantType"  :pendantPicUrl="item.pendantPicUrl"></hotheader>
              <commentbody  @showImg="popupImg" :topicindex="index" :commentindex="i" @replycomment="totopiccomdet" :commenttype="null" :commenttext="item.content" :piclength="item.picUrls.length" :picarray="item.picUrls" :indextopicfont="true" :isIndextopic="true" @indextopicclick="indextopicclick(item.topicId)" :lanxicontent="item.lanxicontent">
              </commentbody>
              <thubm-up :allcount="items.discussLists.length" :topiccommentnum="item.commentCount" :thumbupnum="item.likesNumber" :isup="item.isGood" :topicindex="index" :commentindex="i" @thumbup="topicthumbup" @commentsvgg="totopiccomdet"></thubm-up>
            </div>
          </div>
        </div>

        <!--热门滑动话题-->
        <div class="all-hot-title hot-scroll-topic" v-if="hottopiclist.length>0">热门话题</div>
        <div class="indextopicWrap" ref="indextopicWrap">
          <ul class="indextopicWrap_u" :style="{width:250*(hottopiclist.length)+'rem'}">
            <li v-for="(items,index) in hottopiclist" :key="index">
              <indexscrolltopic @click.native="totopicdet(items,10)" :topicimg="items.topicPicture" :abbreviations="items.abbreviations" :followNumber="items.followNumber" :title="items.title" :topictype="items.isShow"></indexscrolltopic>
            </li>
          </ul>
        </div>

        <!-- 热门说说 -->
        <div class="hot-shuohsuo">
          <div v-if="commentlist&&commentlist.length>0" class="all-hot-title" style="margin-bottom:-0.3rem;">热门说说
          </div>
          <div style="background:#fff;margin-top:0.2rem"  v-for="(item,index) in commentlist" :key="index">
            <hotheader :commentindex="index" :type="1" :nickname="item.name" :saytime="item.timeStamp" :avatarimg="item.head" @topiccommentdetail="tosaycomdet" :place="item.place" :ssshow='item.isRecommend==1' :userType="item.userType"  :isTalent="item.isTalent" :pendantType="item.pendantType" :pendantPicUrl="item.pendantPicUrl"></hotheader>
            <commentbody :commentindex="index" :commenttype="null" @showImg="popupImg" @replycomment="tosaycomdet" :commenttext="item.content" :piclength="item.picture.length" :picarray="item.picture" :isIndexsay="true" @indexsayclick="indexsayclick(item.saysId)" :isdisplacetype="2"></commentbody>
            <thubm-up :topiccommentnum="item.commentNumber" :thumbupnum="item.likes" :commentindex="index" :isup="item.isgood" @thumbup="saythumbup" @commentsvgg="tosaycomdet"></thubm-up>
          </div>
        </div>

        <!-- 热门置换 -->
        <div v-if="replacelist&&replacelist.length>0" class="all-hot-title" style="line-height:0.8rem" >热门闲置
        </div>
        <div class="indexreplaceWrap" ref="indexreplaceWrap" v-if="replacelist&&replacelist.length>0">
          <ul class="indexreplaceWrap_u" :style="{width:375*(replacelist.length)+'rem'}">
            <li v-for="(item,index) in replacelist" :key="index" class="indexreplacecommon">
              <div>
                <displaceheader :avatar="item.head" :commentindex="index" :statustype="item.replacedResult" @torepcommentdetail="torepcomdet" :name="item.name" :time="item.timeStamp" :money="item.price" :userType="item.userType"  :isTalent="item.isTalent" :pendantType="item.pendantType" :pendantPicUrl="item.pendantPicUrl"></displaceheader>
                <commentbodyreplace :repplace="item.place" :commentindex="index" :commenttype="null" :commenttext="item.title" :piclength="item.picture.length" :picarray="item.picture" :description="item.content" :isdisplacetype="2" @replycomment="torepcomdet" @indexreplaceclick="indexreplaceclick(item.replacedId)">
                </commentbodyreplace>
                <thubmUpreplace :topiccommentnum="item.commentNumber" :thumbupnum="item.likes" :commentindex="index" :isup="item.isgood" @thumbup="isdisplacethumbup" @commentsvgg="torepcomdet"></thubmUpreplace>
              </div>
            </li>
          </ul>
        </div>
      <!--更多话题-->
       <div  class="all-hot-title" style="line-height:0.8rem">更多话题</div>
       <div v-for="(items,i) in moretopiclist" :key="i+items.title">
        <indexmoretopic @topicback="totopicdet(items,15)" :topicimg="items.topicPicture" :abbreviations="items.abbreviations" :followNumber="items.followNumber"
                  :title="items.title" :topictype="items.isShow" :tabId="0" :topicItem="items" :topicindex="i" :topiclength="moretopiclist.length"></indexmoretopic>
       </div>
       <p style="padding-bottom:1.05rem;"></p>
      </div>
    </div>
    <div class="buoy-index" @click="goBuoy" v-if="buoyObj&&buoyObj.picture"><img :src="buoyObj.picture" alt=""></div>
    <!--底部导航-->
    <indexnavigation :firstjoin="firstjoin"></indexnavigation>
    <transition name="fade">
      <div class="modal-img" v-if="popupVisible" @click="popupVisible=false">
        <mt-swipe :auto="100000" style="width: 100%;height: 100vh;position:relative;"
        :continuous="false" 
          :defaultIndex="swiperIndex" :showIndicators="false" >
            <mt-swipe-item v-for="(item,index) in popImg" :key="index" style="height:100vh" >
              <img v-lazy="item" class="swiper-img" />
            </mt-swipe-item>
          </mt-swipe>
        </div>
    </transition>
  </div>
</template>

<script type="text/ecmascript-6">
import api from "src/api/index";
import hotheader from "src/components/allhot-header.vue";
import displaceheader from "src/components/hot-displace-header .vue";
import thubmUp from "src/components/thumb-up.vue";
import thubmUpreplace from "src/components/index/thumb-up-replace.vue";
import commentdetailhead from "src/components/commentdetail-header.vue";
import hottopicnew from "src/components/topic/hot-topic-list.vue";
import commentbody from "src/components/comment-detail-body.vue";
import commentbodyreplace from "src/components/index/comment-detail-body-indexreplace.vue";
import ylheader from "src/components/yl-header.vue";
import indexscrolltopic from "src/components/index/indextopicnorecommed.vue";
import indexmoretopic from "src/components/index/index-moretopic.vue";
import indexnavigation from "src/components/index/indexnavigation.vue";
import { Swipe, SwipeItem, Indicator } from "mint-ui";
import tabbar from "src/components/yl-tabbar";
import BScroll from "better-scroll";
import { Marquee, MarqueeItem } from "vux";
import { mapState, mapMutations } from "vuex";
var count = 1;
export default {
  name:"index",
  data() {
    return {
      swiperIndex:0,
      popupVisible:false,
      popImg:'',
      swipeindex: "",//轮播图序号
      urls: [],
      list: [],
      firstjoin:true,
      commentlist: [],
      replacelist: [],
      headline: [],
      isfousexist: false,
      isheadlineempty: false,
      hottopiclist: [],//热门话题（pageorder<11）
      nothotopiclist: [],//不热门话题
      temprelacelist: [],
      defaultreplaceimgsrc:"https://youlingqinius.wonderlandnet.cn/FpwkAospg32-UyJye7fllZf0aRQ7?imageMogr2/auto-orient",//默认闲置图片
      isfirstlogin:0,//0代表不是从幸福绿城进入，1代表从幸福绿城进入
      totalmsgnum:0,//未读消息总数
      rotatetext:"签到",//正常抽奖或者签到抽奖
      hotConfig:{replaced:0,sign:0,says:0,topic:0},//首页hot
      moretopiclist:[],
      is_r: false,
      moretopicidlist:[],
      moretopicids:"",
      tryeat:"http://ot88jre4w.bkt.clouddn.com/Fg4VE4pFqE0Ic3PTderx_2lK6LSY",
      tryoutConfig:{},
      isload:true,
      screenShots:"",
      buoyObj:{},
    };
  },
  components: {
    hotheader,
    displaceheader,
    thubmUp,
    thubmUpreplace,
    commentdetailhead,
    hottopicnew,
    commentbody,
    commentbodyreplace,
    Swipe,
    SwipeItem,
    ylheader,
    tabbar,
    Marquee,
    MarqueeItem,
    indexscrolltopic,
    indexmoretopic,
    indexnavigation
  },
  computed: {
    ...mapState(["indexmoretopicpage","searchresultselected","usercoin"])
  },
  beforeRouteEnter(to, from, next){
      next(vm=>{
        if(from.fullPath=="/"){
          vm.isfirstlogin=1;
        }
      })
  },
  created(){
    this.queryDiscoveryjoin();
    if(localStorage.getItem("jumpType")=="1"&&localStorage.getItem("indexTopicId")!=null){
      localStorage.removeItem("jumpType");
      this.$router.push({
        path: "/topicdetail",
        query: {topicId:localStorage.getItem("indexTopicId"),token:localStorage.getItem("token"),jumpType:"1"}
      });
    }else if(localStorage.getItem("jumpType")=="3"&&localStorage.getItem("indexDrawId")!=null){
      localStorage.removeItem("jumpType");
      this.$router.push({
        path: "/roundrotate",
        query: {drawId:localStorage.getItem("indexDrawId"),isNew:localStorage.getItem("isNew"),token:localStorage.getItem("token"),jumpType:"3"}
      });
    }else if(localStorage.getItem("jumpType")=="4"){
      localStorage.removeItem("jumpType");
      this.$router.push({
        path: "/shuoshuo",
        query: {token:localStorage.getItem("token"),jumpType:"4"}
      });
    }else if(localStorage.getItem("jumpType")=="5"){
      localStorage.removeItem("jumpType");
      this.$router.push({
        path: "/replace",
        query: {token:localStorage.getItem("token"),jumpType:"5"}
      });
    }else if(localStorage.getItem("jumpType")=="6"){
      localStorage.removeItem("jumpType");
      this.$router.push({
        path: "/pointsmall",
        query: {token:localStorage.getItem("token"),jumpType:"6"}
      });
    }else if(localStorage.getItem("jumpType")=="7"){
      localStorage.removeItem("jumpType");
      this.$router.push({
        path: "/tryoutgoodslist",
        query: {tag:0,jumpType:"7"}
      });
    }
  },
  mounted() {
    localStorage.turnCount = (localStorage.turnCount=="index2topicdetail")?"index2topicdetail":"";
    Indicator.open("加载中...");
    this.initIndexList()
      .then(data => {
        return this.initFocuspic();
      })
      .then(data => {
        return this.initUserInfo();
      })
      .then(res => {
        if(this.hottopiclist.length==0){
            return;
        }
        if (!this.scroll) {
          this.scroll = new BScroll(this.$refs.indextopicWrap, {
            scrollX: true,
            tap: "set_cart,changeMastDisplay"
          });
        } else {
          this.scroll.refresh();
        }
      }).then(res => {
        if (this.replacelist.length == 0) {
          return;
        }
        if (!this.replacescroll) {
          this.replacescroll = new BScroll(this.$refs.indexreplaceWrap, {
            scrollX: true,
            tap: "set_cart,changeMastDisplay"
          });
        } else {
          this.replacescroll.refresh();
        }
      }).then(data=>{
        return  this.getmoretopic();
      })
      .then(data => {
        return this.initScroll();
      })
      .then(data => {
        this.$nextTick(() => {
          this.myscroll.refresh();
        });
        // if(localStorage.turnCount=="index2topicdetail"){
          let loadmore = document.getElementsByClassName("loadmore-ul");
          if (loadmore.length > 0) {
            loadmore[0].style.transform = localStorage.turnBackInit;
          }
            localStorage.turnCount = "";
        // }
        //进入首页自动滚动到顶部（不是返回的情况）
        if(this.isfirstlogin==1){
            this.myscroll.scrollTo(0,0);
        }
        if(window.location.search.indexOf("jumpType")!=="-1"){
          //用户在线时长
          this.getUserOnline();
          var that = this;
          var timer = window.setInterval(function(){
                that.getUserOnline();
          },60000);
        }
      })

  },
  methods: {
    ...mapMutations(["changeindexmoretopicpage","changesearchresultselected","changeusercoin"]),
        //显示图片
    popupImg(data,index){
      this.swiperIndex = index
      if(typeof data == 'string'){
        data = data.split(',')
      }
       //console.log(data,index)
      this.popImg = data;
      this.popupVisible = true;
      // console.log(this.swiperOne)
      // this.swiperOne.slideTo(index)
    },
    isInViewport(){
      var h1 = document.getElementsByClassName("hot-scroll-topic")[0];
      // Get it's position in the viewport
      var bounding = h1.getBoundingClientRect();
      // Log the results
      if (
          bounding.top >= 0 &&
          bounding.left >= 0 &&
          bounding.right <= (window.innerWidth || document.documentElement.clientWidth) &&
          bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight)
        ) {
          console.log('In the viewport!');
          // return true;
        } else {
          // return false;
          console.log('Not in the viewport... whomp whomp');
        }
    },
    queryDiscoveryjoin(){
      api.queryDiscoveryjoin().then(res => {
        if(res.success){
          if(res.data.length > 0){
            this.firstjoin = false;
          }else{
            this.firstjoin = true;
          }
        }
      })
    },
    getmoretopic(){
       let p = new Promise((resolve, reject) => {
        if ("index2topicdetail" == localStorage.turnCount) {
          let moretopiclistObj = JSON.parse(localStorage.moretopiclistStorage);
          this.moretopiclist = moretopiclistObj.moretopiclist;
          resolve(true);
        }else{
          api.getmoreTopic({moreList:this.moretopicids}).then(res => {
            if(res.success){
              this.moretopiclist = this.is_r
                  ? [...this.moretopiclist, ...res.data]
                  : res.data;
              if(this.myscroll){
                this.$nextTick(() => {
                  this.myscroll.refresh();
                });
              };
              //排除上次查询话题id
              _each(res.data,(v,j)=>{
                if(j!=res.data.length-1){
                  this.moretopicids += v.topicId+",";
                }else if(j==res.data.length-1){
                  this.moretopicids += v.topicId;
                }
              })
              let moretopiclistObj = JSON.stringify({
                moretopiclist:this.moretopiclist,
              });
              localStorage.moretopiclistStorage = moretopiclistObj;
              resolve("获取更多话题列表...");
              // setTimeout(()=>{ resolve("获取更多话题列表...")},2000)
            }
          })
        }
       });
      return p;
    },
    handleChange(index) {
      this.swipeindex = index;
    },
    showEruda() {
      if (count >= 5) {
        var erdua = sessionStorage.getItem("eruda");
        if (!erdua || erdua === "false") {
          sessionStorage.setItem("eruda", "true");
        } else {
          sessionStorage.setItem("eruda", "false");
        }
        location.reload();
      }
      count++;
    },
    turn2Topic() {
      localStorage.turnCount = "index2topic";
      this.getTransformState();
      const topicclick = {type: 7};
      this.$util.saveclicknum(topicclick);
    },
    turn2say() {
      localStorage.turnCount = "index2say";
      this.getTransformState();
      const sayclick = {type: 8};
      this.$util.saveclicknum(sayclick);
    },
    turn2place() {
      localStorage.turnCount = "index2place";
      this.getTransformState();
      const sayclick = {type: 9};
      this.$util.saveclicknum(sayclick);
    },
    //初始化用户信息
    initUserInfo() {
      let p = new Promise((resolve, reject) => {
        api.QuerygetUserId().then(res => {
          Indicator.close();
          if (res.success) {
            localStorage.setItem("park", res.userinfo.park);
            localStorage.setItem("name", res.userinfo.name);
            localStorage.setItem("nickName", res.userinfo.nickName);
            localStorage.setItem("moblie", res.userinfo.moblie);
            localStorage.setItem("city", res.userinfo.city);
            localStorage.setItem("headImg", res.userinfo.headImg);
            localStorage.setItem("userId", res.userinfo.id);
            localStorage.setItem("type", res.userinfo.type);
            localStorage.setItem("openid", res.userinfo.openid);
            localStorage.setItem("province", res.userinfo.province);
            this.changeusercoin(res.userinfo.coin);
             resolve("得到用户信息...");
            // setTimeout(()=>{ resolve("得到用户信息...");},2000)
          }else{
            // Indicator.close();
          }
        });
      }).catch(err => {
        console.error(err);
        return err;
      });
      return p;
    },
    //获取焦点图
    initFocuspic() {
      let p = new Promise((resolve, reject) => {
        api.Queryindexfocuspic().then(res => {
          if (res.success) {
            this.urls = res.data;
            //焦点图没有则隐藏
            if (res.data.length == 0) {
              this.isfousexist = true;
            }
            _each(this.urls, (v, i) => {
              v.url = v.url + "?imageView2/1/w/750/h/350";
            });
            resolve("得到焦点图...");
          }
            // resolve("得到焦点图...");
        });
      })
      return p;
    },
    //首页的  话题、说说、置换列表
    initIndexList() {
      let p = new Promise((resolve, reject) => {
        api.Queryindex().then(res => {
          if (res.success) {
            if (res.headline == "" || typeof res.headline == "undefined") {
              this.isheadlineempty = true;
            } else {
              this.isheadlineempty = false;
              this.headline = res.headline;
            }
            this.buoyObj = res.buoy;
            this.hotConfig = res.hotConfig;
            this.tryoutConfig = res.tryoutConfig;//试吃
            this.totalmsgnum = res.notRead;
            this.list = res.topic;
            this.gethottopiclist(res.topic);
            this.getdatalanxi(this.nothotopiclist);
            this.topicPicAutoOrient(this.list);
            this.commentlist = res.say;
            this.picAutoOrient(this.commentlist);
            this.replacelist = res.replace;
            this.picAutoOrient(this.replacelist);
            this.getrightrepalcepics(this.replacelist);

            this.$util.getListUrl(res.topic);
            this.$util.getListUrl(res.replace);
            this.$util.getListUrl(res.say);
            resolve("得到列表信息...");
          }else{
            Indicator.close();
          }
        });
      });
      return p;
    },
    //热门推荐闲置图片数量,最少一张，最多3张
    getrightrepalcepics(data){
      _each(data,(v,i)=>{
        if(typeof(v.picture[0])=="undefined"){
           let defaultreplaceimg = new Object();
           defaultreplaceimg.src = this.defaultreplaceimgsrc;
           v.picture.push(defaultreplaceimg);
        }else if(v.picture.length>3){
            v.picture=v.picture.slice(0,3)
        }
      })
    },
    //获取热门与不热门话题列表
    gethottopiclist(data) {
      _each(data, (v, i) => {
        if (v.position&&v.position=="1") {
          this.hottopiclist.push(v);
        } else {
          
        }
        this.nothotopiclist.push(v)
      })
    },
    //设置scroll
    initScroll() {
      let p = new Promise((resolve, reject) => {
        let indexWrapper = this.$refs.indexWrapper;
        localStorage.tempPageHeight = document.getElementsByClassName(
          "loadmore-ul"
        )[0].scrollHeight;
        let _this = this;
        this.$nextTick(() => {
          _this.myscroll = new iScroll(indexWrapper, {
            onScrollStart: function() {
              this.refresh();
            },
            onScrollMove: function() {
              if ((this.y <= (this.wrapperH - this.scroller.clientHeight-50))&& _this.is_r == false&&_this.indexmoretopicpage==1) {
                _this.changeindexmoretopicpage(2);
                _this.is_r = true;
                _this.getmoretopic();
              }
            },
          });
          resolve("初始化scroll");
        });
      });
      Indicator.close();
      return p;
    },
    /**
     * 焦点图点击进入话题详情
     * @param data
     */
    totopicdetail(item,type) {
      const addclick = {
        id: item.topicId,
        type: type
      };
      this.$util.saveclicknum(addclick);
      this.getTransformState();
      this.$router.push({
        path: "/topicdetail",
        query: { topicId: item.topicId, activeId: item.activityId,token:localStorage.getItem("token") }
      });
    },
    /**
     * 首页点击进入话题详情
     * @param data
     */
    totopicdet(items,type) {
      const addclick = {
        id: items.topicId,
        type: 1
      };
      this.$util.saveclicknum(addclick);
      const hottopicclick = {
        id: items.topicId,
        type: type
      };
      this.$util.saveclicknum(hottopicclick);
      this.getTransformState();
      localStorage.turnCount = "index2topicdetail";
      this.$router.push({
        path: "/topicdetail",
        query: { topicId: items.topicId, activeId: items.activityId,token:localStorage.getItem("token") }
      });
    },
    /**
     * 话题点赞
     * @param data
     */
    topicthumbup(data) {
      this.topicId = this.nothotopiclist[data.topicindex].topicId;
      const param = {
        type: 0,
        typeId: this.nothotopiclist[data.topicindex].discussLists[data.commentindex].id,
        recMsgId: this.nothotopiclist[data.topicindex].discussLists[data.commentindex]
          .userId,
        topicId: this.topicId
      };
      if (
        this.nothotopiclist[data.topicindex].discussLists[data.commentindex].isGood == 0
      ) {
        api.Querytopicsavegood(param).then(res => {
          if (res.success) {
            if (res.isGood == 1) {
              this.nothotopiclist[data.topicindex].discussLists[
                data.commentindex
              ].isGood = 1;
              this.nothotopiclist[data.topicindex].discussLists[
                data.commentindex
              ].likesNumber =
                res.data;
            }
          }
        });
        //记录点击数
        const hottopicclick = {
          id: this.topicId,
          type: 10
        };
        this.$util.saveclicknum(hottopicclick);
      } else if (
        this.nothotopiclist[data.topicindex].discussLists[data.commentindex].isGood == 1
      ) {
        api.QuerytopicCanaleGood(param).then(res => {
          if (res.success) {
            if (res.isGood == 0) {
              this.nothotopiclist[data.topicindex].discussLists[
                data.commentindex
              ].isGood = 0;
              this.nothotopiclist[data.topicindex].discussLists[
                data.commentindex
              ].likesNumber =
                res.data;
            }
          }
        });
        //记录点击数
        const hottopicclick = {
          id: this.topicId,
          type: 10
        };
        this.$util.saveclicknum(hottopicclick);
      }
    },

    /**
     * 说说点赞
     * @param data
     */
    saythumbup(data) {
      const params = {
        saysId: this.commentlist[data.commentindex].saysId,
        createSaysUserId: this.commentlist[data.commentindex].userId
      };
      if (this.commentlist[data.commentindex].isgood == 0) {
        api.Querysaythumbup(params).then(res => {
          if (res.success) {
            if (res.isGood == 1) {
              this.commentlist[data.commentindex].isgood = 1;
              this.commentlist[data.commentindex].likes = res.data;
            }
          }
        });
      //记录点击数
      const hotsayclick = {
        id:  this.commentlist[data.commentindex].saysId,
        type: 11
      };
      this.$util.saveclicknum(hotsayclick);
      } else if (this.commentlist[data.commentindex].isgood == 1) {
        api.Querysaycanclethumbup(params).then(res => {
          if (res.success) {
            if (res.isGood == 0) {
              this.commentlist[data.commentindex].isgood = 0;
              this.commentlist[data.commentindex].likes = res.data;
            }
          }
        });
        //记录点击数
        const hotsayclick = {
          id:  this.commentlist[data.commentindex].saysId,
          type: 11
        };
        this.$util.saveclicknum(hotsayclick);
      }
    },

    /**
     * 置换点赞
     * @param data
     */
    isdisplacethumbup(data) {
      const params = {
        replacedId: this.replacelist[data.commentindex].replacedId,
        createReplacedUserId: this.replacelist[data.commentindex].userId
      };
      if (this.replacelist[data.commentindex].isgood == 0) {
        api.Queryreplacethumbup(params).then(res => {
          if (res.success) {
            this.replacelist[data.commentindex].isgood = 1;
            this.replacelist[data.commentindex].likes = res.data;
          }
        });
        var replaceclick = {
          replacedId: this.replacelist[data.commentindex].replacedId,
          type:12
        };
        this.$util.saveclicknum(replaceclick);
      } else if (this.replacelist[data.commentindex].isgood == 1) {
        api.Querycanclereplacethumbup(params).then(res => {
          if (res.success) {
            this.replacelist[data.commentindex].isgood = 0;
            this.replacelist[data.commentindex].likes = res.data;
          }
        });
        var replaceclick = {
          replacedId: this.replacelist[data.commentindex].replacedId,
          type:12
        };
        this.$util.saveclicknum(replaceclick);
      }
    },

    /**
     * 点击跳转到话题的评论详情
     * @param data
     */
    totopiccomdet(data) {
        //记录点击数
      const hottopicclick = {
        id: this.nothotopiclist[data.topicindex].topicId,
        type: 10
      };
      this.$util.saveclicknum(hottopicclick);
      this.getTransformState();
      this.$router.push({
        path: "/commentsdetail",
        query: {
          type: 0,
          commentId: this.nothotopiclist[data.topicindex].discussLists[data.commentindex].id,
          topicId: this.nothotopiclist[data.topicindex].topicId,
          topicIndex:0
        }
      });
    },

    /**
     * 点击跳转到说说的评论详情
     * @param data
     */
    tosaycomdet(data) {
      //记录点击数
      const hotsayclick = {
        id: this.commentlist[data.commentindex].saysId,
        type: 11
      };
      this.$util.saveclicknum(hotsayclick);
      this.getTransformState();
      this.$router.push({
        path: "/shuodetail",
        query: { saysId: this.commentlist[data.commentindex].saysId ,shuoshuoIndex:data.commentindex}
      });
    },
    searchindex() {
      this.getTransformState();
      var searchclick = {type:6};
      this.$util.saveclicknum(searchclick);
      this.changesearchresultselected(0);
      this.$router.push("/search");
    },
    torepcomdet(data) {
      this.getTransformState();
      var replaceclick = {
        replacedId: this.replacelist[data.commentindex].replacedId,
        type:12
      };
      this.$util.saveclicknum(replaceclick);
      this.$router.push({
        path: "/replacedetail",
        query: { replacedId: this.replacelist[data.commentindex].replacedId,replaceIndex: data.commentindex }
      });
    },
    //获取跳转前的位置
    getTransformState() {
      let loadmore = document.getElementsByClassName("loadmore-ul");
      if (loadmore.length > 0) {
        localStorage.turnBackInit = loadmore[0].style.transform;
      }
    },
    //图片自动旋转参数
    picAutoOrient(data) {
      for (var m = 0; m < data.length; m++) {
        if (data[m].picture != null) {
          for (var n = 0; n < data[m].picture.length; n++) {
            data[m].picture[n].src =
              data[m].picture[n].src + "?imageMogr2/auto-orient";
          }
        }
      }
    },
    //图片自动旋转参数(话题讨论)
    topicPicAutoOrient(data) {
      for (var m = 0; m < data.length; m++) {
        if (data[m].discussLists != null) {
          for (var n = 0; n < data[m].discussLists.length; n++) {
            for (var i = 0; i < data[m].discussLists[n].picUrls.length; i++) {
              data[m].discussLists[n].picUrls[i].src =
                data[m].discussLists[n].picUrls[i].src +
                "?imageMogr2/auto-orient";
            }
          }
        }
      }
    },
    //热门头条跳转详情
    headlineclick(items) {
       //话题点击id
      const topicclick = {
        id: items.topicId,
        type: 1
      };
      //头条点击id
      const headlineclick = {
        id: items.id,
        type: 5
      };
      this.$util.saveclicknum(topicclick);
      this.$util.saveclicknum(headlineclick);
      if(items.type==1){//话题
         this.$router.push({
            path: "/topicdetail",
            query: { topicId: items.topicId, activeId: items.activityId,token:localStorage.getItem("token")}
          });
      }else if(items.type==2){//说说
        //  this.$router.push({
        //     path: "/topicdetail",
        //   });
        window.open(items.linkUrl)
      }else if(items.type==3){//试吃试用
          this.$router.push({
            path: "/tryoutDetails",
            query: { id: items.tryoutGoodsId,type:items.tryoutGoodsType}
          });
      }
    },
    getUserOnline(){
      api.getuseronline().then(res => {})
    },
    //点击热门话题图片记录点击次数
    indextopicclick(topicId){
      const topicclick = {
        id: topicId,
        type: 10
      };
      this.$util.saveclicknum(topicclick);
    },
    //点击热门说说图片记录点击次数
    indexsayclick(saysId){
      const sayclick = {
        id: saysId,
        type: 11
      };
      this.$util.saveclicknum(sayclick);
    },
    indexreplaceclick(replacedId){
      const replaceclick = {
        id: replacedId,
        type: 12
      };
      this.$util.saveclicknum(replaceclick);
    },
    //跳转我的
    mineclick(){
      const mineclick = {
        type: 13
      };
      this.$util.saveclicknum(mineclick);
      this.$router.push({path:'/mine'}) ;
    },
    changeTitle(){
      if (bridge) {
        bridge._init();
        bridge.callSetTitle("扎希特勒");
      }
    },
    getdatalanxi(data){
        _each(data,(m,j)=>{
          _each(m.discussLists,(v,i)=>{
            if(v.content&&v.content.indexOf("://?")!=-1){
              if(v.content.split("://?").length>3){
                let tempcontent = new Object();
                tempcontent.lanxitext = v.content.split("://?")[1];
                tempcontent.lanxiurltext = v.content.split("://?")[2];
                tempcontent.lanxiurl = v.content.split("://?")[3];
                v.lanxicontent = tempcontent;
              }else{
                v.lanxicontent = new Object();
              }
            }
          })
         })
    },
    gorotate(){
      this.$util.saveclicknum({type:19});
      this.$router.push({
        path: "/pointsmall",
        query: { drawId: this.drawId}
      });
      // this.$router.push({
      //   path: "/checkin",
      //   query: { drawId: this.drawId}
      // });
    },
    getsignin(){
      api.getsignin().then(res=>{
        if(res.success){
          this.$toast("签到成功");
          setTimeout(() => {this.gorotate()},1000);
        }
      });
    },
    turnSkipUrl(item,type){
       Indicator.open("加载中...");
       setTimeout(()=>{
          Indicator.close()
       },3000)
      const addclick = {
        id: item.id,
        type: 4
      };
      this.$util.saveclicknum(addclick);

      if(item.skipType==0){
        const addclick = {
          id: item.topicId,
          type: 1
        };
        this.$util.saveclicknum(addclick);
      }
      if(item.skipUrl.indexOf("?")>-1){
        window.location.href=item.skipUrl+"&token="+localStorage.getItem("token")
      }else{
        window.location.href=item.skipUrl+"?token="+localStorage.getItem("token")
      }
    },
    goBuoy(){
      if(this.buoyObj&&this.buoyObj.jumpUrl!=null){
        window.location.href=this.buoyObj.jumpUrl
      }
    }
  }
};
</script>

<style lang="less" scoped>
.modal-img{
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,.5);
  position: fixed;
  top:0;
  left: 0;
  z-index: 9999;
  img{
    width: 80%;
    position: absolute;
    top:50%;
    left: 10%;
    transform: translateY(-50%);
  }
  .swiper-img{
    height: auto;
  }
}
.tryeat{
  margin: 0.2rem 0.3rem 0;
  background: #ffffff;
  height: 1.6rem;
}
.tryeat img{
  height: 100%;;
  width: 100%;
  border-radius: 0.1rem;
}
.swiper-img {
  width: 100%;
  height: 3.8rem;
}

.hot-icon {
  height: 1.8rem;
  background-color: white;
  display: flex;
  padding: 0 0.8rem 0.02rem 0.8rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.2rem;

}

.hot-icon-title {
  text-align: center;
  font-size: 0.26rem;
  font-family: "PingFangSC Regular";
  color: #4b4d4b;
}

.all-hot-title {

  background: #f5f5f5;
  height: 0.8rem;
  padding-left: 0.3rem;
  line-height: 0.75rem;
  font-size: 0.3rem;
  font-family: "PingFangSC Regular";
  color: #3a3a3a;
}

.mint-swipe-indicator.is-active {
  background: #a0c0d8 !important;
  opacity: 1;
  border: none;
  width: 0.16rem;
  height: 0.16rem;
}

.mint-swipe-indicator {
  opacity: 0.8;
  background: #a0c0d8;
  border: 0.02rem solid white;
  width: 0.12rem;
  height: 0.12rem;
}

.topic-hot-title {
  height: 0.88rem;
  background-color: white;
  line-height: 0.88rem;
  font-size: 0.28rem;
  font-family: "PingFangSC Regular";
  color: #3a3a3a;
  border-bottom: 1px solid #e6e6e6;
  text-align: center;
}
.loadmore-container {
  height: 95vh;
  overflow: hidden;
  margin: 0 auto;
}

.loadmore-ul {
  padding-bottom: 0.2rem;
  list-style: none;
}

.nofocuspic {
  display: none;
}

.all-top-headlines {
  display: flex;
  background: #fff;
  /* margin-bottom: 0.2rem; */
}

.headlines {
  display: flex;
  align-items: center;
  padding-top: 0.2rem;
  margin:0 0.3rem;
  padding-bottom: 0.2rem;
}

.top-headlines {
  height: 0.3rem;
  text-align: center;
  color: #fb685b;
  width: 1.18rem;
  font-size: 0.24rem;
  background:url("../../assets/topheadline.png") no-repeat;
  background-size: 100% 100%;
}

.marquee-all {
  color: #333333;
  font-size: 0.26rem;
  width: 5.38rem;
  margin-left: 0.15rem;
}

.vux-marquee-box li {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: PingFangSC-Regular, sans-serif;
}

.nodata {
  display: none;
}

.indexhoticon {
  border-bottom: 1px solid #f0f0f0;
  background-color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.indexhoticonimg {
  width: 0.9rem;
  height: 0.9rem;
}

.indexhoticonall {
  border-right: 1px solid #f0f0f0;
  text-align: center;
  flex: 1;
  padding: 0.2rem 0;
}

.indextopicWrap {
  overflow: hidden;
}

.indextopicWrap_u {
  overflow-y: auto;
  white-space: nowrap;
  background: #f5f5f5;
}


.indextopicWrap_u li {
  margin-left: 0.2rem;
  display: inline-block;
  width: 4.3rem;
  height: 3.2rem;
  line-height: 3.2rem;
  text-align: center;
}

.indextopicWrap_u li a {
  width: 4.3rem;
  height: 3.2rem;
  font-size: 15px;
  display: inline-block;
  color: #333;
  transition: border 0.5s linear;
  line-height: 3.2rem;
}

.indexreplaceWrap {
  overflow: hidden;
}

.indexreplaceWrap_u {
  overflow-y: auto;
  white-space: nowrap;
  background: #f5f5f5;
  display: flex
}

.indexreplaceWrap_u li {
  background: #ffffff;
  border-radius: 10px;
  margin-left: 0.25rem;
  width: 6.5rem;
  height: 5.9rem;
  position: relative;
}

.swipeindicator {
  font-size: 0.22rem;
  display: flex;
  color: #fff;
  position: absolute;
  right: 0.15rem;
  bottom: 0.28rem;
}

.swipeindicatorback {
  position: absolute;
  right: 0;
  bottom: 0.45rem;
  width: 1.3rem;
  height: 0.16rem;
}

.swipeindicatorselecet {
  padding-right: 0.1rem;
  font-weight: bold
}
.hoticon{
  width: 0.44rem;
  position: absolute;
  height: 0.24rem;
  top: 0.07rem;
  right: 0.3rem;
}
.hot-discuss{
  border-top: 1px solid #E6E6E6;
}
.top-headlines-fa{
  height:0.5rem;
  display: flex;
  align-items: center;
  width:100%;
}
.top-headlines-label{
  border:1px solid #3da4fa;
  color:#3da4fa;
  border-radius: 0.06rem;
  padding:0 0.05rem;
  height: 0.38rem;
  line-height: 0.38rem;
  display: flex;
  align-items: center;
  font-size: 0.24rem;
}
.top-headlines-title{
 margin-left:  0.15rem;
   white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.buoy-index{
  position: fixed;
  bottom: 1.7rem;
  right: 0.3rem;
  img{
    width:1.2rem;
    height: 1.2rem;
  }
}
</style>
